package com.ziyear.prometheus.task;

import com.ziyear.prometheus.service.ZtUserService;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@EnableScheduling
@Component
public class TestTask {

    @Autowired
    private ZtUserService userService;

    @Scheduled(cron = "0/5 * * * * ?")
    public void runTask() {
        long count = userService.count();
        log.info("task run local time : {},count{}",
            LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), count);

    }
}
